/********************************************************
* Projet Chat System
* 
* Yann MBOUNGOU et Jean-Christophe VENDOME
* ELEVES INGENIEUR - 4e Année - Informatique et Réseaux
* INSA TOULOUSE, Dept. GEI - 2014 - 2015
*********************************************************/
package GUI;
import java.awt.*;
import javax.swing.*;

public class Graphisme extends JFrame {
     JPanel mainPanel,authPanel,msgPanel,sendPanel,privatePanel; 
     JButton connect,disc,send,File,retour,psend,pFile;     
     private JTextField jftlogin;
     JTextField jftmessage,pftmessage;
     private JList jUserList;
     JScrollPane scroll,scroll2;
     JColorTextPane msg;
    
     @SuppressWarnings("OverridableMethodCallInConstructor")
    public Graphisme()
    {
    super("CHAT SYSTEM");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setSize(500,380);
    mainPanel=new JPanel();
    mainPanel.setPreferredSize(new Dimension(500,400));
    this.add(mainPanel);

    /******************  authPanel  **********************///panel d'authentification
    authPanel=new JPanel();
    authPanel.setBackground(new java.awt.Color(204, 204, 255)); 
    authPanel.setPreferredSize(new Dimension(500,100));
    authPanel.add(new JLabel("Login :"));
    jftlogin=new JTextField("",12);
    authPanel.add(getJftlogin());
    connect=new JButton("CONNECT");  
    connect.setBackground(new java.awt.Color(204, 255, 204));
    connect.setForeground(new java.awt.Color(0, 0, 0));
    authPanel.add(connect);
    mainPanel.add(authPanel); //Au démarrage panel existant ds le mainPanel
    
     /******************  msgPanel  **********************///panel de chat
    msgPanel=new JPanel();      
    msgPanel.setBackground(new java.awt.Color(204, 204, 255));  
    msgPanel.setPreferredSize(new Dimension(500,200));
    msg=new JColorTextPane();
    //msg.setColumns(20);
    //msg.setRows(5);
    scroll=new JScrollPane();
    scroll2=new JScrollPane();
    scroll.setViewportView(msg);   
    jUserList = new JList();
    getjUserList().setModel(new javax.swing.AbstractListModel() 
    {
        String[] strings = {"users LIST's"};
        @Override
        public int getSize() 
        { 
            return strings.length;
        }
        @Override
        public Object getElementAt(int i) 
        { 
            return strings[i]; 
        }
    });
    GroupLayout msgPanelLayout = new GroupLayout(msgPanel);
        msgPanel.setLayout(msgPanelLayout);
        msgPanelLayout.setHorizontalGroup(
            msgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, msgPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scroll2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(scroll)
                .addContainerGap())
        );
        msgPanelLayout.setVerticalGroup(
            msgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scroll)           
            .addComponent(scroll2, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
        );    
    mainPanel.add(msgPanel);
    
    /******************  sendPanel  **********************///panel de message à tout le monde
    sendPanel=new JPanel();
    sendPanel.setBackground(new java.awt.Color(204, 204, 255)); 
    sendPanel.setPreferredSize(new Dimension(500,100));
    sendPanel.add(new JLabel("Message :"));
    jftmessage=new JTextField("",12);
    sendPanel.add(jftmessage);
    send=new JButton("SEND");
    sendPanel.add(send);        
    send.setBackground(new java.awt.Color(0,0,255));
    send.setForeground(new java.awt.Color(0, 0, 0));
    File = new JButton("File");
    File.setBackground(new java.awt.Color(255, 255, 0));
    File.setForeground(new java.awt.Color(0, 0, 0));
    sendPanel.add(File);
    disc=new JButton("DISCONNECT");   
    disc.setBackground(new java.awt.Color(255, 0, 51));
    disc.setForeground(new java.awt.Color(0, 0, 0));
    sendPanel.add(disc);
        
    setVisible(true);// En dernier
  }

    public JTextField getJftlogin() {
        return jftlogin;
    }

    public JList getjUserList() {
        return jUserList;
    }
}
